home *** CD-ROM | disk | FTP | other *** search
- /*
- **
- ** $VER: IconGad PLUGIN V1.10 (08-Feb-98) - By Fabio Rotondo
- **
- ** Name : IconGad PLUGIN
- **
- ** Copyright :
- ** EMail : fsoft@intercom.it
- ** WWW : http://www.intercom.it/~fsoft
- **
- ** ProgID : $01
- ** ProgrammerID : $03
- **
- ** Version : 1.10
- ** Date : 01-Feb-98
- **
- ** Notes : Fixed AND enhanced by: Jason Hulance (jason@fsel.com)
- ** Comments between /* */ are mine (Fabio)
- ** Comments satrting with -> are from Jason
- **
- **
- ** History : 1.00 - Inital Release
- **
- ** 1.10 - Now it is (I hope) EasyPLUGINs StyleGuide Compliant :-)
- **
- ** - Added ICONGAD constant TO use instead of PLUGIN one in your
- ** interfaces.
- **
- ** - Added the disabled() method.
- */
-
-
- OPT OSVERSION=37
- OPT MODULE
- OPT EXPORT
-
-
- MODULE 'workbench/workbench',
- 'exec/ports',
- 'icon',
- 'intuition/screens', 'intuition/intuition',
- 'gadtools', 'libraries/gadtools',
- 'tools/easygui', 'tools/Exceptions'
-
-
- CONST ICONGAD_BASE = $83010000
-
- CONST ICONGAD = PLUGIN
-
-
- /*
- This is our new plugin.
- Note the PRIVATE keyword:
- we don't want the user to access these fields.
- */
-
- OBJECT icongad_plugin OF plugin
- PRIVATE
- dobj:PTR TO diskobject
- -> Have our own gadget (don't use dobj's gadget)
- gad:PTR TO gadget
- disabled
- ENDOBJECT
-
- /*
- This is the init proc for the plugin.
- You must provide a valid icon name (full path)
- without the ".info" extension (it is added automagically
- by GetDiskObject() call)
- */
- PROC init(fname) OF icongad_plugin
- IF (iconbase:=OpenLibrary('icon.library', 0))=NIL THEN Raise("ilib")
- self.dobj := GetDiskObject(fname)
- IF self.dobj = NIL THEN Raise("icon")
-
- -> Copy the relevant parts of dobj to our gadget
- -> The *vital* part is the initialisation of the "activation" field to
- -> a known value (GACT_RELVERIFY). That way, we know what IDCMP messages
- -> the gadget will generate.
-
- self.gad:=NEW [NIL, 0, 0, self.dobj.gadget.width, self.dobj.gadget.height,
- self.dobj.gadget.flags, GACT_RELVERIFY,
- self.dobj.gadget.gadgettype,
- self.dobj.gadget.gadgetrender,
- self.dobj.gadget.selectrender,
- NIL, 0, NIL, 0, NIL]:gadget
- ENDPROC
-
- /*
- We free all Alloc()ed resources.
- Remeber to always END your PLUGINs before program termination.
- */
- PROC end() OF icongad_plugin
- IF self.dobj THEN FreeDiskObject(self.dobj)
- IF iconbase THEN CloseLibrary(iconbase)
- END self.gad
- ENDPROC
-
- /* The icon cannot be stretched, so it cannot be resized... */
- PROC will_resize() OF icongad_plugin IS FALSE
-
-
- /* We provide, as min size, the Icon size */
- PROC min_size(ta, fh) OF icongad_plugin IS self.gad.width, self.gad.height
-
-
- /* This is the render proc */
- PROC render(ta, x,y, xs, ys, win:PTR TO window) OF icongad_plugin
- IF self.gh = NIL THEN RETURN
- IF win = NIL THEN RETURN
-
- IF self.gad
- self.gad.leftedge:=x
- self.gad.topedge :=y
- AddGadget(win, self.gad, NIL)
- -> The final argument to RefreshGList() ought to be 1, not 0
- RefreshGList(self.gad, win, NIL, 1)
-
- self.change_status(win)
- ENDIF
- ENDPROC
-
- PROC change_status(win) OF icongad_plugin
- IF self.disabled
- OffGadget(self.gad, win, NIL)
- ELSE
- OnGadget(self.gad, win, NIL)
- ENDIF
- ENDPROC
-
-
- /*
- And here there is the clear proc
- Since we have created a standard gadget, we simply
- remove it from the gadget list of the window.
- */
- PROC clear_render(win:PTR TO window) OF icongad_plugin
- IF self.gad THEN IF win THEN RemoveGadget(win, self.gad)
- ENDPROC
-
- PROC message_test(imsg:PTR TO intuimessage, win:PTR TO window) OF icongad_plugin
- -> Because we set the gadget's activation field we know we'll only get
- -> IDCMP_GADGETUP generated by our gadget.
- IF (imsg.class=IDCMP_GADGETUP) THEN RETURN imsg.iaddress=self.gad
- ENDPROC FALSE
-
- PROC message_action(a,b,c,d) OF icongad_plugin IS TRUE
-
- PROC disabled(dis=TRUE) OF icongad_plugin
- IF dis<>self.disabled
- self.disabled:=dis
-
- IF self.gh = NIL THEN RETURN
- IF self.gh.wnd = NIL THEN RETURN
-
- self.change_status(self.gh.wnd)
- ENDIF
- ENDPROC
-
-